#include<iostream>
#include<iterator>
#include<algorithm>
using namespace std;

void InsertSort(int* array, int size)
{
    for (int i = 1; i < size; ++i)
    {
        int t = array[i];
        int pos = i - 1;
        
        for (; -1 != pos && t < array[pos]; --pos)
        {
            array[pos + 1] = array[pos];
        }
        array[pos + 1] = t;
        
        copy(array, array + size, ostream_iterator<int>(cout, " "));
        cout<<endl;
    }
}

int main(void)
{
    int array[] = {52, 49, 80, 36, 14, 58, 61, 23, 97, 75};
    int size = sizeof(array) / sizeof(array[0]);
    
    InsertSort(array, size);
    
    system("pause");
}
